module.exports = (app) => {
  const mongoose = app.mongoose;
  mongoose.pluralize(null);
  const Schema = mongoose.Schema;
  const UseraddressSchema = new Schema(
    {
      // 每次查找都去查找用户id
      userId: {
        type: mongoose.Types.ObjectId,
        ref: "Userinfo",
        required: true,
        localField: "userId",
        foreignField: "_id",
      },
      name: {
        type: String,
        required: true,
      },
      gender: {
        type: Number,
        required: true,
      },
      phone: {
        type: String,
        required: true,
      },
      //   省市区
      address: {
        type: String,
        required: true,
      },
      //   具体街道
      detail: {
        type: String,
        required: true,
      },
      // 标签
      label: {
        type: String,
      },
      //  是否默认
      isDefault: {
        type: Boolean,
        default: false,
      },
    },
    { versionKey: false }
  );
  return mongoose.model("Useraddress", UseraddressSchema);
};
